﻿using System.Xml.Serialization;

namespace Toybox.NicoSharp.Live
{
	using Utilities;

	/// <summary>
	/// StreamInfoクラス
	/// </summary>
	[XmlRoot("getstreaminfo")]
	public partial class StreamInfo : NicoSharp.Abstracts.AbstractStatus
	{

		#region [Static]

		/// <summary>
		/// StreamInfo取得
		/// </summary>
		/// <param name="id">放送ID</param>
		/// <returns></returns>
		public static StreamInfo Get(string completeId)
		{
			string url = NicoUrls.WatchLiveApi + "getstreaminfo/" + completeId;
			string xml = NicoWebClient.Get(url);
			return Deserializer.XmlDeserializer<StreamInfo>(xml);
		}

		#endregion [Static]


		#region Public Members

		/// <summary>
		/// 放送ID
		/// </summary>
		public string request_id;

		/// <summary>
		/// ストリーム情報
		/// </summary>
		public InnerStreamInfo streaminfo;

		/// <summary>
		/// コミュニティ情報
		/// </summary>
		public CommunityInfo communityinfo;

		/// <summary>
		/// 広告
		/// </summary>
		public Adsense adsense;

		#endregion Public Members


		#region [SubClass]

		/// <summary>
		/// ストリームクラス
		/// </summary>
		public class InnerStreamInfo
		{
			/// <summary>
			/// タイトル
			/// </summary>
			public string title;

			/// <summary>
			/// 説明
			/// </summary>
			public string description;

			/// <summary>
			/// 放送プロバイダ
			/// </summary>
			public ProviderType provider_type;

			/// <summary>
			/// コミュニティ
			/// </summary>
			public string default_community;
		}

		/// <summary>
		/// コミュニティ情報
		/// </summary>
		public class CommunityInfo
		{
			/// <summary>
			/// コミュニティ名
			/// </summary>
			public string name;

			/// <summary>
			/// コミュニティサムネイル
			/// </summary>
			public string thumbnail;
		}

		/// <summary>
		/// 広告
		/// </summary>
		public class Adsense
		{
			/// <summary>
			/// 広告単体
			/// </summary>
			public class Item
			{
				/// <summary>
				/// 広告名
				/// </summary>
				public string name;

				/// <summary>
				/// 広告URL
				/// </summary>
				public string url;
			}

			/// <summary>
			/// 広告
			/// </summary>
			[XmlElement]
			public Item[] item;
		}

		#endregion [SubClass]

	}
}